package com.wwk.phone.service.impl;

import com.github.pagehelper.Page;
import com.wwk.phone.dao.UserDao;
import com.wwk.phone.entity.User;
import com.wwk.phone.service.UserService;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;

/**
 * (User)表服务实现类
 *
 * @author makejava
 * @since 2023-06-08 13:08:13
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public User queryById(Long id) {
        return this.userDao.queryById(id);
    }


    /**
     * 新增数据
     *
     * @param user 实例对象
     * @return 实例对象
     */
    @Override
    public User insert(User user) {
        this.userDao.insert(user);
        return user;
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.userDao.deleteById(id) > 0;
    }

    @Override
    public User checkUser(String username, String password) {
        return userDao.findByUsernamePassword(username, password);
    }
}
